import time as t

class poisoning():
    def __init__(self,unit,time) -> None:
        self.name = "poisoning"
        self.unit = unit
        self.time = time
        self.start_time = t.time()
        self.finish_time = self.start_time + self.time
    def effect(self):
        now = int(t.time())
        if now > self.start_time:
            self.start_time = now
            self.unit.healthy -= self.unit.maxhealthy*0.1
            self.unit.healthyOnChange()
        if now >= self.finish_time:
            self.delete_self()
    def delete_self(self):
        del self.unit.statuses[self.name]